package uk.co.drpj.rep;

import java.util.SortedSet;

public class ArrayMap implements Map {
	private int map[];
	
	public ArrayMap(int [] map) {
		this.map=new int[map.length];
		System.arraycopy(map, 0, this.map, 0, map.length);
	}
	
	public ArrayMap(SortedSet<Integer> map) {
		this.map=new int[map.size()];
		int cnt=0;
		for(int i:map) {
			this.map[cnt++]=i;
		}
	}

	public int lookUp(int i){
		return map[i%map.length];
	}

	public int indexOf(int findMe) {
		for (int i=0;i<map.length;i++) {
			if (map[i] == findMe) return i;
		}
		return Map.ERROR;
	}

	public int size() {
		return map.length;
	}
}
